package com.zr.rocketmq.consumer;

import com.zr.rocketmq.entity.Order;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

@Slf4j
@Component
// 消费事务订单消息
@RocketMQMessageListener(topic = "order_transaction_topic", consumerGroup = "transaction_order_consumer_group", selectorExpression = "pay")
public class TransactionOrderConsumer implements RocketMQListener<Order> {

    @Override
    public void onMessage(Order order) {
        log.info("收到事务订单消息，开始处理支付...");
        log.info("订单ID: {}", order.getOrderId());
        log.info("支付金额: {}", order.getAmount());
        
        // 这里可以添加支付处理逻辑
        log.info("支付处理完成，状态更新为PAID");
    }
}
